#coding=utf-8
import time
import sys
from config.config import logger
from libraries.strptime import TimeParser

#日期转int
def formate(data,fmat='%Y-%m-%d %H:%M:%S'):
    d= time.mktime(time.strptime(data,fmat))
    return int(d)

#日期
def formate_date(data,fmat='%Y-%m-%d'):
    d= time.mktime(time.strptime(data,fmat))
    return int(d)

#字符串时间
def strptime(string, format="%a %b %d %H:%M:%S %Y"):
    return TimeParser(format).match(string)
#自定义日期    
def mytimer(set_time):
    DATEFORMAT = '%Y-%m-%d '
    DATETIMEFORMAT = '%Y-%m-%d %H:%M:%S'
    second = 0.0
    date = time.strftime(DATEFORMAT,time.localtime())
    request_time = date + set_time

    second = formate(request_time) - time.mktime(time.localtime())
    print(second)
    return
    if second<0.0:
        second = 24*60*60 + second
    logger.info("sleep %s" %second)
    
    time.sleep(second)

mytimer("17:40:10")

